import React, { Component } from 'react';
// import { Router, Route, hashHistory, IndexRedirect } from 'react-router';
import { Route, Redirect, Switch } from 'react-router-dom';
import Dashboard from '../components/Dashboard/Dashboard';
import Todo from '../components/Todo/Todo';
import Project from '../components/Project/Project';

export default class CRouter extends Component {
    requireAuth = (permission, component) => {
        const { auth } = this.props;
        const { permissions } = auth.data;
        // const { auth } = store.getState().httpData;
        if (!permissions || !permissions.includes(permission)) return <Redirect to={'404'} />;
        return component;
    };
    render() {
        return (
            <Switch>
                <Route exact path="/app/dashboard/index" component={Dashboard} />
                <Route exact path="/app/todo/index" component={Todo} />
                <Route exact path="/app/project/index" component={Project} />
                {/* <Route render={() => <Redirect to="/404" />} /> */}
            </Switch>
        )
    }
}